import { SongDetailProp, SongProp, StateProp } from './type'
import storage from 'good-storage'
import { PLAY_MODE, STATE_KEY } from '@/assets/js/constant'

export default {
    updateSongVal (state: StateProp, song: SongProp | null) {
        state.song = song
        storage.session.set(STATE_KEY, state)
    },
    setSequenceList (state: StateProp, sequenceList: SongDetailProp[]) {
        state.sequenceList = sequenceList
        storage.session.set(STATE_KEY, state)
    },
    setPlayingState (state: StateProp, playingState: boolean) {
        state.playingState = playingState
        storage.session.set(STATE_KEY, state)
    },
    setFullScreen (state: StateProp, fullScreen: boolean) {
        state.fullScreen = fullScreen
        storage.session.set(STATE_KEY, state)
    },
    setPlayList (state: StateProp, playList: SongDetailProp[]) {
        state.playList = playList
        storage.session.set(STATE_KEY, state)
    },
    setCurrentIndex (state: StateProp, currentIndex: number) {
        state.currentIndex = currentIndex
        storage.session.set(STATE_KEY, state)
    },
    setPlayMode (state: StateProp, playMode: PLAY_MODE) {
        state.playMode = playMode
        storage.session.set(STATE_KEY, state)
    },
    setFavoriteList (state: StateProp, favoriteList: SongDetailProp[]) {
        state.favoriteList = favoriteList
    }
}
